export const Router = {
	push(options) {
		if (typeof options == 'string') {
			return uni.navigateTo({
				url: options
			});
		}

		let {
			path,
			mode = 'navigateTo',
			animationType,
			animationDuration,
			success,
			fail,
			complete,
			query
		} = options || {};

		if (query) {
			let arr = [];

			for (let i in query) {
				arr.push(`${i}=${query[i]}`);
			}

			path += '?' + arr.join('&');
		}

		uni[mode]({
			url: path,
			animationType,
			animationDuration,
			success,
			fail,
			complete
		});
	},

	pushTab(path) {
		this.push({
			path,
			mode: 'switchTab'
		});
	},

	back(options) {
		const { delta = 1, animationDuration, animationType } = options || {};

		uni.navigateBack({
			delta,
			animationDuration,
			animationType
		});
	}
};
